home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The X-Philes (2nd Revision)
/
The X-Philes Number 1 (1995).iso
/
xphiles
/
hp48_2
/
fx
< prev
next >
Wrap
Internet Message Format
|
1995-03-31
|
17KB
From: Chris Tham <christie@extro.ucc.su.OZ.AU>
Subject: v03i005: fx - Currency Two-way Pricing v1.0, Part01/01
Newsgroups: comp.sources.hp48
Followup-To: comp.sys.hp48
Approved: spell@seq.uncwil.edu
Checksum: 1521524764 (verify with brik -cv)
Submitted-by: Chris Tham <christie@extro.ucc.su.OZ.AU>
Posting-number: Volume 3, Issue 5
Archive-name: fx/part01
BEGIN_RDME fx.doc
HP-48SX Foreign Currency Bid/Offer Pricing/Conversions Version 1.0
Copyright (C) 1991 Chris Tham
Introduction
The HP-48SX FX Application performs bid/offer quotations, pricing, and
cross currency rate calculations for use by professional Foreign
Exchange market makers. It allows the user to define a set of
currencies and set two-way prices (quotes) for each currency against
the reference currency (the US Dollar denoted by the three character
code `USD'). Both direct and indirect methods of quoting currencies
are supported by the application. Each currency can then be priced on
both the bid and offer sides against any other currency defined and the
application will automatically perform the necessary cross rate
calculation, taking the appropriate side of the two-way quotes.
Background
Foreign Exchange currency conversions/pricing are different from
scientific unit conversions normally performed by the HP-48SX Units
Application because there are two, instead of one, conversion factors
associated with each currency.
In the foreign exchange market, dealers buy and sell one currency in
exchange for another currency. Basically, the price or value of money
in one country is traded against money in another country. A foreign
exchange transaction always involve two currencies, one of which can be
considered the currency bought or sold (the `base' or `commodity'
currency) and the other currency can be considered the measure of value
for effecting the transaction (the `terms' currency).
All transactions require two counterparties, each of which will both buy
and sell currency. The exchange rate is the price at which one currency
can be exchange for another. Currency names are abbreviated using
standard codes developed for computer input (the United States Dollar is
designated by `USD', the Australian Dollar `AUD', the Japanese Yen `JPY',
the German Deutschmark `DEM', the Great Britain Pound Sterling `GBP'
and so on).
For example, one counterparty may purchase 1 million AUD (value is
Australian Dollars $1,000,000) against the US Dollar at an exchange rate
of AUD 1 = USD 0.7800 (or, in standard market quotation, AUD/USD 0.7800).
This means that the counterparty has to pay (or sell) $780,000 US
Dollars for the Australian Dollars bought. The transaction can also be
viewed as the counterparty exchanging USD for AUD, paying USD 0.7800 for
every AUD 1 received. The other counterparty is performing the reverse
action, exchanging AUD for USD, and receiving USD 0.7800 for every AUD 1
sold.
The exchange rate between any two currencies is normally quoted as the
number of terms currency units required to purchase or sell one base
currency unit. The exchange rate is expressed by the commodity currency
code, followed by a slash, followed by the terms currency code and then
the exchange rate in terms currency units. In the above example, the
exchange rate is quoted with AUD being the base currency and USD being
the terms currency, hence AUD/USD 0.7800. In foreign exchange trading,
the commodity currency is usually the focus of trading and dealers buy
and sell multiples of the commodity currency.
Instead of quoting each currency against every other currency, all
currencies are normally quoted against the US Dollar. The exchange rate
between any two currency can then be determined by referencing against
the exchange rate for each currency against the US Dollar. Most
currencies are quoted against the US Dollar with the US Dollar as the base
(or commodity) currency. This is also called direct quotation. Some
currencies, however, notably those belonging to the so called
`Commonwealth' countries including Great Britain and Australia, are
quoted with the US Dollar as the terms currency. This method of quoting
is referred to as indirect quoting. An example of a direct quotation is
USD/DEM 1.8200 (note USD is the base currency and appears on the left
hand side of the slash). An example of an indirect quotation is
GBP/USD 1.6293 (USD is now the terms currency and appears on the right
hand side of the slash).
There is no `standard' or `reference' exchange rate for any country
against the US Dollar (except when countries fix currency exchange
rates with respect to other currencies). Instead, each dealer is free
to set the exchange rate for the currency that the dealer is prepared to
trade. By convention, dealers set two exchange rates, a rate in which
they are prepared to buy the commodity currency (the bid rate) and a
rate in which they are prepared to sell the commodity currency (the
offer rate). This is called two-way pricing or quotation. By convention,
the bid rate is quoted before the offer rate. Hence, a typical two-way
quote for AUD would be AUD/USD 0.7800/05. This means that the bid rate
for AUD/USD is 0.7800 and the offer rate is 0.7805, i.e. the dealer is
prepared to buy AUD for USD 0.7800 and sell AUD for USD 0.7805. The
difference between the offer and bid quotes, i.e. USD 0.0005 or
5 `points', is called the `spread' and represents the dealer's profit
from buying and selling the commodity currency.
How to use the FX application
The FX application is normally stored in a subdirectory on the HP-48SX
called `FX'. To use the application, simply enter the directory and
either type the `GO' command or press the [VAR] menu key and then press
the soft key marked [GO] (this should be the left most soft key if you
have not created any variables in this directory). The screen' soft
menu labels should now change to something like the following
[MKC] [RMC] [USD] [AUD] [DEM]
The soft keys [MKC] and [RMC] are used to define and undefine a new
currency unit. The remaining soft key labels denote currency codes.
WHen you first install the application, the application comes
preconfigured with three currencies, USD, AUD and DEM. You are allowed
to create or delete any currencies that you wish, including the
predefined AUD and DEM currencies. However, USD is a special currency
that cannot be created or deleted at will due to its special status as
the currency against which all other currencies are valued against.
Let's use the predefined currencies first. Later, we will try creating
and deleting currencies and see the effect on the soft menu. Suppose
you are a market maker dealing in both AUD and DEM and you are currently
quoting
AUD/USD 0.7790/95
USD/DEM 1.8155/60
Your bids and offers may be entered into the application by typing in a
complex number with the real part equal to the bid rate and the imaginary
part equal to the offer rate, then pressing [Right Shift] followed by
the currency soft menu key. In this instance, you will type in
[Left SHift] [ () ] 0.7790 [SPC] 0.7795 [ENTER] [Right Shift] [AUD]
[Left SHift] [ () ] 1.8155 [SPC] 1.8160 [ENTER] [Right Shift] [DEM]
Note that the application `knows' that AUD is normally quoted in
indirect terms and DEM is normally quoted in direct terms so you can
just enter the quotes into the application and it will figure out which
currency is the base currency and which is the terms currency.
Now if you buy AUD 15 million how much USD should you be selling? The
sign convention is positive if you are buying and negative if you are
selling. Type in the following
15 [EEX] 6 [AUD]
and level 1 of the stack will now show something like
15000000.0000_bAUD
My calculator is currently on FIX 4 mode. Your calculator may show a
slightly different format depending on your current numeric display
mode. Note that the amount 15,000,000 is suffixed by the string "_bAUD"
indicating that the amount is in AUD and you are buying that currency
and hence `bidding' for it. To convert that amount to USD, simply press
the [Left Shift] [USD] key and level 1 of the stack will change to
-11685000.0000_oUSD
Hence, to buy AUD 15 million, you need to sell USD 11.685 million.
What if you were to sell AUD 15 million? They following keystrokes will
reveal the answer:
15 [+/-] [EEX] 6 [AUD] [Left Shift] [USD]
The stack should show
11692500.0000_bUSD
which means you will receive USD 11.6925 million.
Here are some more examples and their answers
1. Buying DEM 6 million (6000000.0000_bDEM), pay
-3303964.7577_oUSD
{Keystrokes: 6 [EEX] 6 [DEM] [Left Shift] [USD]}
2. Selling AUD 7 million (-7000000.0000_oAUD), receive
9909004.0000_bDEM
{Keystrokes: 7 [+/-] [EEX] 6 [AUD] [Left Shift] [DEM]}
3. Buying USD 2 million (2000000.0000_bUSD), pay
-2565747.2739_oAUD
{Keystrokes: 2 [EEX] 6 [USD] [Left Shift] [AUD]}
To create a new currency, you need to know
* the three letter currency code
* bid/offer rates of that currency against the US dollar
* whether the currency is normally quoted in direct or indirect form
As an example, suppose you want to create a new currency called GBP
(Great Britain Pound Sterling). You will be quoting GBP/USD 1.6930/35
(i.e., indirectly).
Enter the following keystrokes:
[Right Shift] [" "] [Alpha] [Alpha] G B P [ENTER]
[Left Shift] [ () ] 1.6930 [SPC] 1.6935 [ENTER]
0 [ENTER]
The stack should show:
3: "GBP"
2: (1.6930,1.6935)
1: 0.0000
Level 3 contains the three character currency code, i.e., GBP, level 2
contains the quoted exchange rate of GBP against USD, level 1 is 0 for
an indirect quote (and 1 for a direct quote).
Now press the [MKC] (Make Currency) soft key. You should now notice a
new softkey labelled [GBP] on the soft menu. You can now perform
currency conversions using GBP:
How much do you receive in GBP if you sell DEM 44,000?
Keystrokes:
44 [+/-] [EEX] 3 [DEM] [Left Shift] [GBP]
Answer:
14315.2674_bGBP
How do you create a new currency called "SFR" (Swiss Francs) to be
quoted as USD/SFR 1.5520/25 (direct quotation)?
Keystrokes:
[Right Shift] [" "] [Alpha] [Alpha] S F R [ENTER]
[Left Shift] [ () ] 1.5520 [SPC] 1.5525 [ENTER]
1 [ENTER]
[MKC]
To remove a currency, simply create a string containing the currency
code of the currency to be removed, then press the [RMC] (Remove
Currency) soft key. For example, to remove the SFR currency just
created, press
[Right Shift] [" "] [Alpha] [Alpha] S F R [ENTER] [RMC]
The soft menu should automatically reflect the removal of the currency.
Exiting the FX application
Just press any menu key.
Installing the FX application
Upload FX.ASC, FX.BIN or FX.48 into the directory where you wish
to place the 'FX' directory on the HP-48SX (normally the HOME
directory).
END_RDME
BEGIN_ASC fx.asc
%%HP: T(3)A(D)F(.);
"69A20FF7FD900000003055354430ADA209C2A2C2A2070000D668B01B2130A200
02024F420D9D20E163292CF14B2A2B9DE1C2A20B000013F526C2A20B000013F5
F6EF3A1DBBF176BA162BC193632B2130F5000303424F430D9D20E1632C2A2090
000722692CF176BA1C2A20700007276BA162BC1DBBF1C2A209000072F6DBBF17
6BA1C2A20700007276BA162BC193632B2130F700040343545F440D9D20E16328
4E20303424F41C432D6E201005D6E201024D6E2010F4E1632ADA209C2A2C2A20
B000055354468B01B2130D6E201005AC7C192CF1EEDA1D6E201024DCC02D6E20
1005918C1DBBF1EEDA1D6E2010F4DCC02EF53293632B21307C000403494E4654
0D9D20E1632E89C1872B1DBBF1872B1E97C193632B2130930004034F4554540D
9D20E1632DBBF1599A1DBBF184E202024F4BD69193632B2130F3000303494E43
0D9D20E163284E202024F4DBBF1B1791EEDA193632B2130830003025D43430D9
D20E16321C432D6E2010D4E163284E205034D454E455A59C11C432D6E2010E4E
16329C2A2D6E2010E430132D6E2010E45BCF13CE2278BF1B0BC1D6E2010D44BA
C1AFE22D9D208DBF145632D6E2010E497632AA9028DBF1B21305DF22C4232D6E
2010E4387C14563284E205034D454E45597632DCC02D6E2010D484E20303424F
4EFE02EFE0284E202074F4EF532EF53293632B21306310030D4B43430D9D20E1
6321C432D6E201014D6E201024D6E201034E1632C2A20F0000B702B70222D6E2
0101476BA1C2A20310002202B702BA022276BA1D6E20101476BA1C2A20B10002
2023494E402BB02BA022276BA1D6E20101476BA1C2A20B1000220234F4554502
BB02BA0276BA13CE22D6E201034AFE22D9D20C2A20F0000023494E46576BA1B2
1305DF22C2A20700002276BA1D6E20101476BA1C2A20700002276BA1C2A20D10
00343545F402BB02D702D702D776BA162BC184E205034D454E455DBBF176BA14
563284E205034D454E45597632DCC02D6E2010243CE22D6E201034AFE2284E20
403494E4655DF22D6E20101484E2040343545F447A2084E202074F4B21309DF0
284E202074F4EF53293632B2130C220040F64454D440ADA20339209991638442
180550C2A20B000055354468B01B21300400040264454D440ADA203392099925
92970660550C2A20B000055354468B01B21300400040F614554440ADA2033920
9990000000059770C2A20B000055354468B01B213004000402614554440ADA20
339209990000000009770C2A20B000055354468B01B21300400040F655354440
ADA209C2A2C2A20B000055354468B01B213003000402655354440ADA209C2A2C
2A20B000055354468B01B2130030005034D454E4555047A2084E2030D4B43484
E203025D43447A20C2A20B000055354447A20D9D20E1632C2A20B00005535448
4E20303494E493632B2130D9D20E1632C2A20B000055354484E204034F455459
3632B21308DBF1B2130B213047A20C2A20B000014554447A20D9D20E1632C2A2
0B000014554484E20303494E493632B2130D9D20E1632C2A20B000014554484E
204034F4554593632B2130D9D20E1632C2A20B000014554484E2040343545F49
3632B2130B2130B213047A20C2A20B00004454D447A20D9D20E1632C2A20B000
04454D484E20303494E493632B2130D9D20E1632C2A20B00004454D484E20403
4F4554593632B2130D9D20E163284E20403494E465C2A20B00004454D484E204
0343545F493632B2130B2130B2130B2130442002074F420D9D20E163284E2050
34D454E455D511293632B2130185A"
END_ASC
BYTES: #A581h 1299
BEGIN_UU fx.uue
begin 644 fx.bin
M2%!(4#0X+466*O!_WPD #55-$ ]HJD"PJ+"IP !MA@NQ$@,J " @]"30
MV0(>-I+"'[2BLMD>+"JP Q7V(L*K #%?;_ZCT;L?9ZMALAPY-K(2 U\
M,# D]#30V0(>-L*B @D <"*6PA]GJ\&B @< <'*V&B;+T;L?+"J0 G;[W[
M<;8:+"IP G9ZMALAPY-K(2 W\ 0# T1?5$T-D"'C:"Y (#0T)/P332Y@(!
M4&TN$"#4Y@(!3QXVHJT"R:+"H@(+ % U162X$"LQT.8" 5#*QY'"'^ZMT>8"
M 4+-#-+F @%0&<C1NQ_NK='F @%/S0SB7R,Y-K(2 \< 0#"4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$@-T*L"B
M @L $%1%1*<"G2W@82,L*K $%51$@N,#"4Y)1C(RLQT-D"'C;"H@(+ !!4
M183D @1#3U54.3:R$@.=+>!A(RPJL 055$2"Y ,#1%]91C(RLQL!(#*S%
MIP(L*K $1%370JT-D"'C;"H@(+ $!4U(3D @-#24XY-K(2 YTMX&$C+"JP
M !$14U(+D P]%1%E6,C*S'0V0(>-H+D @1#24Y6+"JP !$14U(+D P-$7U
IE&,C*S&P$@,K,; 2 T0"('#T)-#9 AXV@N0"!4--14Y571&28R,K,0 P
end
END_UU
BEGIN_RPL fx.rpl
%%HP: T(3)A(D)F(.);
DIR
GO
\<< CMENU TMENU
\>>
CMENU { MKC RMC {
"USD" {
\<< "USD" CIN
\>>
\<< "USD" COUT
\>> DROP } } {
"AUD" {
\<< "AUD" CIN
\>>
\<< "AUD" COUT
\>>
\<< "AUD" CSTO
\>> } } { "DEM" {
\<< "DEM" CIN
\>>
\<< "DEM" COUT
\>>
\<< CINV "DEM"
CSTO
\>> } } }
bUSD '1_USD'
oUSD '1_USD'
bAUD '.779_USD'
oAUD '.7795_USD'
bDEM '
.550660792952_USD'
oDEM '
.550812448361_USD'
MKC
\<< \-> A B C
\<< C$ 5 { { "
A + C$ 7 " { \<< " +
A +
C$ 11 " CIN \>> \<< " +
A +
C$ 11 " COUT \>> \<< +
IF C
THEN
" CINV" +
END C$ 1 "
+ A + C$ 1 " +
"CSTO \>> } } }" +
STR\-> CMENU SWAP +
'CMENU' STO B
IF C
THEN CINV
END A CSTO
{ GO } ORDER GO
\>>
\>>
RMC
\<< \-> M
\<< CMENU LIST\->
\-> N
\<< 1 N
START N
ROLL
IF DUP
\->STR M POS
THEN
DROP 'N' DECR DROP
END
NEXT N
\->LIST 'CMENU' STO M
CBO PURGE PURGE GO
\>>
\>>
\>>
CIN
\<< BO SWAP UVAL
*
\>>
COUT
\<< SWAP NEG SWAP
BO CONVERT
\>>
CINV
\<< C\->R INV SWAP
INV R\->C
\>>
CSTO
\<< CBO \-> P B O
\<< '1_USD' P
RE OVER * B STO P
IM SWAP * O STO
\>>
\>>
CBO
\<< "'b" OVER +
"'" + STR\-> SWAP
"'o" SWAP + "'" +
STR\->
\>>
BO
\<< OVER 0 \>=
"1_b" "1_o" IFTE
SWAP + STR\->
\>>
USD '1_m'
END
END_RPL
christie@extro.ucc.su.oz.au